package com.ziJing.multithreading.visibility;

import com.ziJing.multithreading.helper.SleepHelper;

/**
 * @program Multithreading
 * @description:
 * @author: zhangbo
 * @create: 2022/04/26 22:16
 */
public class Visibility01 {

    private static /*volatile*/ boolean running = true;

    private static void m() {
        System.out.println("m start");
        while (running){
            //println 中使用了synchronized，所以也会刷到内存
//            System.out.println("hello");
        }
        System.out.println("m end!");
    }

    public static void main(String[] args) {

        new Thread(Visibility01::m, "t1").start();

        SleepHelper.sleepSeconds(1);

        running = false;

    }
}
